# -*- coding:utf-8 -*-
from tkinter import *
from tkinter import ttk
from db import get_one_by_id
from PIL import Image, ImageTk
import os


class ItemEdit(Toplevel):
    def __init__(self, rf_id):
        super().__init__()
        self.minsize(400, 200)
        self.rf_id = rf_id
        self.rfcode = StringVar()
        self.sskb = StringVar()
        self.rfcode.set(rf_id)
        row = get_one_by_id(rf_id)
        self.sskb.set(row[1])
        self.title(f'{rf_id}修改')
        self.grab_set()  # modal
        # 弹窗界面
        self.setup_UI()

    def setup_UI(self):
        sw = self.winfo_screenwidth()
        sh = self.winfo_screenheight()
        ww = 400
        wh = 200
        x = (sw - ww) / 2
        y = (sh - wh) / 2
        self.geometry("%dx%d+%d+%d" % (ww, wh, x, y))
        # 第一行（两列）
        frame_top = ttk.Frame(self)
        frame_top["relief"] = "solid"
        ttk.Label(frame_top, text='枪号').grid(row = 2, column = 0)
        ttk.Entry(frame_top, textvariable=self.rfcode).grid(row = 2, column = 1)
        ttk.Label(frame_top, text='名字').grid(row = 4, column = 0)
        ttk.Entry(frame_top, textvariable=self.sskb).grid(row = 4, column = 1)
        ttk.Button(frame_top, text='确定').grid(row = 6, column = 0)
        ttk.Button(frame_top, text='取消').grid(row = 6, column = 1)
        frame_top.pack(side=TOP)

    def show(self, event):
        pass

